package com.example.test.util;

import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Font;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.tool.xml.XMLWorkerFontProvider;

/**
 * @Author 林文峰
 * @Date 2020/7/1 0001 15:30
 */
public class DefineFontProvider extends XMLWorkerFontProvider {
	
	@Override
	public Font getFont(final String fontname, final String encoding, final boolean embedded, final float size,
						final int style, final BaseColor color) {
		BaseFont bf = null;
		try {
			bf = BaseFont.createFont("F:\\下载位置\\simsun.ttc", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
		} catch (Exception e) {
			e.printStackTrace();
		}
		Font font = new Font(bf, size, style, color);
		font.setColor(color);
		return font;
	}
}
